package org.ccay.core.exception.impl;

import javax.inject.Named;

import org.ccay.core.base.IExecutable;
import org.ccay.core.exception.ApplicationException;
import org.ccay.core.exception.IKillExceptionBox;
import org.ccay.core.log.ILogger;

/**
 * 记录日志并消灭异常的BOX，不处理Error
 * 
 * @since 2013-3-22
 */
@Named("logAndKillBox")
public class LogAndKillBox implements IKillExceptionBox {

	/* (non-Javadoc)
	 * @see org.ccay.core.exception.IKillExceptionBox#run(org.ccay.core.log.ILogger, org.ccay.core.base.IExecutable)
	 */
	public void run(ILogger logger, IExecutable executable) {
		try{
			executable.execute();
		} catch(ApplicationException ex){
			logger.error(ex);
		} catch(RuntimeException ex){
			logger.error(ex);
		} catch(Error ex){
			//记录Error但不处理
			logger.error(ex);
			throw ex;
		}
	}

}
